########## MACROS ###########################################################################
#############################################################################################

function(conan_message MESSAGE_OUTPUT)
    if(NOT CONAN_CMAKE_SILENT_OUTPUT)
        message(${ARGV${0}})
    endif()
endfunction()


macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS FRAMEWORKS_DIRS)
    if(APPLE)
        foreach(_FRAMEWORK ${FRAMEWORKS})
            # https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
            find_library(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND NAMES ${_FRAMEWORK} PATHS ${FRAMEWORKS_DIRS} CMAKE_FIND_ROOT_PATH_BOTH)
            if(CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND)
                list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_${_FRAMEWORK}_FOUND})
            else()
                message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${FRAMEWORKS_DIRS}")
            endif()
        endforeach()
    endif()
endmacro()


function(conan_package_library_targets libraries package_libdir deps out_libraries out_libraries_target build_type package_name)
    unset(_CONAN_ACTUAL_TARGETS CACHE)
    unset(_CONAN_FOUND_SYSTEM_LIBS CACHE)
    foreach(_LIBRARY_NAME ${libraries})
        find_library(CONAN_FOUND_LIBRARY NAMES ${_LIBRARY_NAME} PATHS ${package_libdir}
                     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
        if(CONAN_FOUND_LIBRARY)
            conan_message(STATUS "Library ${_LIBRARY_NAME} found ${CONAN_FOUND_LIBRARY}")
            list(APPEND _out_libraries ${CONAN_FOUND_LIBRARY})
            if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
                # Create a micro-target for each lib/a found
                string(REGEX REPLACE "[^A-Za-z0-9.+_-]" "_" _LIBRARY_NAME ${_LIBRARY_NAME})
                set(_LIB_NAME CONAN_LIB::${package_name}_${_LIBRARY_NAME}${build_type})
                if(NOT TARGET ${_LIB_NAME})
                    # Create a micro-target for each lib/a found
                    add_library(${_LIB_NAME} UNKNOWN IMPORTED)
                    set_target_properties(${_LIB_NAME} PROPERTIES IMPORTED_LOCATION ${CONAN_FOUND_LIBRARY})
                    set(_CONAN_ACTUAL_TARGETS ${_CONAN_ACTUAL_TARGETS} ${_LIB_NAME})
                else()
                    conan_message(STATUS "Skipping already existing target: ${_LIB_NAME}")
                endif()
                list(APPEND _out_libraries_target ${_LIB_NAME})
            endif()
            conan_message(STATUS "Found: ${CONAN_FOUND_LIBRARY}")
        else()
            conan_message(STATUS "Library ${_LIBRARY_NAME} not found in package, might be system one")
            list(APPEND _out_libraries_target ${_LIBRARY_NAME})
            list(APPEND _out_libraries ${_LIBRARY_NAME})
            set(_CONAN_FOUND_SYSTEM_LIBS "${_CONAN_FOUND_SYSTEM_LIBS};${_LIBRARY_NAME}")
        endif()
        unset(CONAN_FOUND_LIBRARY CACHE)
    endforeach()

    if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
        # Add all dependencies to all targets
        string(REPLACE " " ";" deps_list "${deps}")
        foreach(_CONAN_ACTUAL_TARGET ${_CONAN_ACTUAL_TARGETS})
            set_property(TARGET ${_CONAN_ACTUAL_TARGET} PROPERTY INTERFACE_LINK_LIBRARIES "${_CONAN_FOUND_SYSTEM_LIBS};${deps_list}")
        endforeach()
    endif()

    set(${out_libraries} ${_out_libraries} PARENT_SCOPE)
    set(${out_libraries_target} ${_out_libraries_target} PARENT_SCOPE)
endfunction()


########### FOUND PACKAGE ###################################################################
#############################################################################################

include(FindPackageHandleStandardArgs)

conan_message(STATUS "Conan: Using autogenerated FindArrow.cmake")
set(Arrow_FOUND 1)
set(Arrow_VERSION "17.0.0")

find_package_handle_standard_args(Arrow REQUIRED_VARS
                                  Arrow_VERSION VERSION_VAR Arrow_VERSION)
mark_as_advanced(Arrow_FOUND Arrow_VERSION)

set(arrow_COMPONENTS arrow::parquet_static arrow::arrow_static)

if(Arrow_FIND_COMPONENTS)
    foreach(_FIND_COMPONENT ${Arrow_FIND_COMPONENTS})
        list(FIND arrow_COMPONENTS "arrow::${_FIND_COMPONENT}" _index)
        if(${_index} EQUAL -1)
            conan_message(FATAL_ERROR "Conan: Component '${_FIND_COMPONENT}' NOT found in package 'arrow'")
        else()
            conan_message(STATUS "Conan: Component '${_FIND_COMPONENT}' found in package 'arrow'")
        endif()
    endforeach()
endif()

########### VARIABLES #######################################################################
#############################################################################################


set(arrow_INCLUDE_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_INCLUDE_DIR "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_INCLUDES "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_RES_DIRS )
set(arrow_DEFINITIONS "-DPARQUET_STATIC"
			"-DARROW_STATIC")
set(arrow_LINKER_FLAGS_LIST
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:>"
)
set(arrow_COMPILE_DEFINITIONS "PARQUET_STATIC"
			"ARROW_STATIC")
set(arrow_COMPILE_OPTIONS_LIST "" "")
set(arrow_COMPILE_OPTIONS_C "")
set(arrow_COMPILE_OPTIONS_CXX "")
set(arrow_LIBRARIES_TARGETS "") # Will be filled later, if CMake 3
set(arrow_LIBRARIES "") # Will be filled later
set(arrow_LIBS "") # Same as arrow_LIBRARIES
set(arrow_SYSTEM_LIBS pthread m dl rt)
set(arrow_FRAMEWORK_DIRS )
set(arrow_FRAMEWORKS )
set(arrow_FRAMEWORKS_FOUND "") # Will be filled later
set(arrow_BUILD_MODULES_PATHS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib/cmake/conan-official-arrow-targets.cmake")

conan_find_apple_frameworks(arrow_FRAMEWORKS_FOUND "${arrow_FRAMEWORKS}" "${arrow_FRAMEWORK_DIRS}")

mark_as_advanced(arrow_INCLUDE_DIRS
                 arrow_INCLUDE_DIR
                 arrow_INCLUDES
                 arrow_DEFINITIONS
                 arrow_LINKER_FLAGS_LIST
                 arrow_COMPILE_DEFINITIONS
                 arrow_COMPILE_OPTIONS_LIST
                 arrow_LIBRARIES
                 arrow_LIBS
                 arrow_LIBRARIES_TARGETS)

# Find the real .lib/.a and add them to arrow_LIBS and arrow_LIBRARY_LIST
set(arrow_LIBRARY_LIST parquet arrow)
set(arrow_LIB_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib")

# Gather all the libraries that should be linked to the targets (do not touch existing variables):
set(_arrow_DEPENDENCIES "${arrow_FRAMEWORKS_FOUND} ${arrow_SYSTEM_LIBS} re2::re2;Boost::Boost;jemalloc::jemalloc;thrift::thrift;AWS::aws-sdk-cpp-cognito-identity;AWS::aws-sdk-cpp-core;AWS::aws-sdk-cpp-identity-management;AWS::aws-sdk-cpp-s3;AWS::aws-sdk-cpp-sts;xsimd::xsimd;zstd::zstd")

conan_package_library_targets("${arrow_LIBRARY_LIST}"  # libraries
                              "${arrow_LIB_DIRS}"      # package_libdir
                              "${_arrow_DEPENDENCIES}"  # deps
                              arrow_LIBRARIES            # out_libraries
                              arrow_LIBRARIES_TARGETS    # out_libraries_targets
                              ""                          # build_type
                              "arrow")                                      # package_name

set(arrow_LIBS ${arrow_LIBRARIES})

foreach(_FRAMEWORK ${arrow_FRAMEWORKS_FOUND})
    list(APPEND arrow_LIBRARIES_TARGETS ${_FRAMEWORK})
    list(APPEND arrow_LIBRARIES ${_FRAMEWORK})
endforeach()

foreach(_SYSTEM_LIB ${arrow_SYSTEM_LIBS})
    list(APPEND arrow_LIBRARIES_TARGETS ${_SYSTEM_LIB})
    list(APPEND arrow_LIBRARIES ${_SYSTEM_LIB})
endforeach()

# We need to add our requirements too
set(arrow_LIBRARIES_TARGETS "${arrow_LIBRARIES_TARGETS};re2::re2;Boost::Boost;jemalloc::jemalloc;thrift::thrift;AWS::aws-sdk-cpp-cognito-identity;AWS::aws-sdk-cpp-core;AWS::aws-sdk-cpp-identity-management;AWS::aws-sdk-cpp-s3;AWS::aws-sdk-cpp-sts;xsimd::xsimd;zstd::zstd")
set(arrow_LIBRARIES "${arrow_LIBRARIES};re2::re2;Boost::Boost;jemalloc::jemalloc;thrift::thrift;AWS::aws-sdk-cpp-cognito-identity;AWS::aws-sdk-cpp-core;AWS::aws-sdk-cpp-identity-management;AWS::aws-sdk-cpp-s3;AWS::aws-sdk-cpp-sts;xsimd::xsimd;zstd::zstd")

set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH  ${CMAKE_PREFIX_PATH})


########### COMPONENT arrow_static VARIABLES #############################################

set(arrow_arrow_static_INCLUDE_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_arrow_static_INCLUDE_DIR "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_arrow_static_INCLUDES "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_arrow_static_LIB_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib")
set(arrow_arrow_static_RES_DIRS )
set(arrow_arrow_static_DEFINITIONS "-DARROW_STATIC")
set(arrow_arrow_static_COMPILE_DEFINITIONS "ARROW_STATIC")
set(arrow_arrow_static_COMPILE_OPTIONS_C "")
set(arrow_arrow_static_COMPILE_OPTIONS_CXX "")
set(arrow_arrow_static_LIBS arrow)
set(arrow_arrow_static_SYSTEM_LIBS pthread m dl rt)
set(arrow_arrow_static_FRAMEWORK_DIRS )
set(arrow_arrow_static_FRAMEWORKS )
set(arrow_arrow_static_BUILD_MODULES_PATHS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib/cmake/conan-official-arrow-targets.cmake")
set(arrow_arrow_static_DEPENDENCIES Boost::Boost jemalloc::jemalloc re2::re2 thrift::thrift AWS::aws-sdk-cpp-cognito-identity AWS::aws-sdk-cpp-core AWS::aws-sdk-cpp-identity-management AWS::aws-sdk-cpp-s3 AWS::aws-sdk-cpp-sts xsimd::xsimd zstd::zstd)
set(arrow_arrow_static_LINKER_FLAGS_LIST
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:>"
)

########### COMPONENT parquet_static VARIABLES #############################################

set(arrow_parquet_static_INCLUDE_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_parquet_static_INCLUDE_DIR "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_parquet_static_INCLUDES "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/include")
set(arrow_parquet_static_LIB_DIRS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib")
set(arrow_parquet_static_RES_DIRS )
set(arrow_parquet_static_DEFINITIONS "-DPARQUET_STATIC")
set(arrow_parquet_static_COMPILE_DEFINITIONS "PARQUET_STATIC")
set(arrow_parquet_static_COMPILE_OPTIONS_C "")
set(arrow_parquet_static_COMPILE_OPTIONS_CXX "")
set(arrow_parquet_static_LIBS parquet)
set(arrow_parquet_static_SYSTEM_LIBS )
set(arrow_parquet_static_FRAMEWORK_DIRS )
set(arrow_parquet_static_FRAMEWORKS )
set(arrow_parquet_static_BUILD_MODULES_PATHS "/root/.conan/data/arrow/17.0.0/milvus/dev/package/496f940df09f90e46bf405e2943f541bd0255fec/lib/cmake/conan-official-arrow-targets.cmake")
set(arrow_parquet_static_DEPENDENCIES arrow::arrow_static re2::re2)
set(arrow_parquet_static_LINKER_FLAGS_LIST
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>:>"
        "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:>"
)


########## FIND PACKAGE DEPENDENCY ##########################################################
#############################################################################################

include(CMakeFindDependencyMacro)

if(NOT re2_FOUND)
    find_dependency(re2 REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency re2 already found")
endif()

if(NOT Boost_FOUND)
    find_dependency(Boost REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency Boost already found")
endif()

if(NOT jemalloc_FOUND)
    find_dependency(jemalloc REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency jemalloc already found")
endif()

if(NOT Thrift_FOUND)
    find_dependency(Thrift REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency Thrift already found")
endif()

if(NOT AWSSDK_FOUND)
    find_dependency(AWSSDK REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency AWSSDK already found")
endif()

if(NOT AWSSDK_FOUND)
    find_dependency(AWSSDK REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency AWSSDK already found")
endif()

if(NOT AWSSDK_FOUND)
    find_dependency(AWSSDK REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency AWSSDK already found")
endif()

if(NOT AWSSDK_FOUND)
    find_dependency(AWSSDK REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency AWSSDK already found")
endif()

if(NOT AWSSDK_FOUND)
    find_dependency(AWSSDK REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency AWSSDK already found")
endif()

if(NOT xsimd_FOUND)
    find_dependency(xsimd REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency xsimd already found")
endif()

if(NOT zstd_FOUND)
    find_dependency(zstd REQUIRED)
else()
    conan_message(STATUS "Conan: Dependency zstd already found")
endif()


########## FIND LIBRARIES & FRAMEWORKS / DYNAMIC VARS #######################################
#############################################################################################

########## COMPONENT arrow_static FIND LIBRARIES & FRAMEWORKS / DYNAMIC VARS #############

set(arrow_arrow_static_FRAMEWORKS_FOUND "")
conan_find_apple_frameworks(arrow_arrow_static_FRAMEWORKS_FOUND "${arrow_arrow_static_FRAMEWORKS}" "${arrow_arrow_static_FRAMEWORK_DIRS}")

set(arrow_arrow_static_LIB_TARGETS "")
set(arrow_arrow_static_NOT_USED "")
set(arrow_arrow_static_LIBS_FRAMEWORKS_DEPS ${arrow_arrow_static_FRAMEWORKS_FOUND} ${arrow_arrow_static_SYSTEM_LIBS} ${arrow_arrow_static_DEPENDENCIES})
conan_package_library_targets("${arrow_arrow_static_LIBS}"
                              "${arrow_arrow_static_LIB_DIRS}"
                              "${arrow_arrow_static_LIBS_FRAMEWORKS_DEPS}"
                              arrow_arrow_static_NOT_USED
                              arrow_arrow_static_LIB_TARGETS
                              ""
                              "arrow_arrow_static")

# 添加缺失的 Boost::Boost 目标定义
if(NOT TARGET Boost::Boost)
    add_library(Boost::Boost INTERFACE IMPORTED)
    set_target_properties(Boost::Boost PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
        INTERFACE_LINK_LIBRARIES "${Boost_LIBRARIES}")
endif()

set(arrow_arrow_static_LINK_LIBS ${arrow_arrow_static_LIB_TARGETS} ${arrow_arrow_static_LIBS_FRAMEWORKS_DEPS})

set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH  ${CMAKE_PREFIX_PATH})

########## COMPONENT parquet_static FIND LIBRARIES & FRAMEWORKS / DYNAMIC VARS #############

set(arrow_parquet_static_FRAMEWORKS_FOUND "")
conan_find_apple_frameworks(arrow_parquet_static_FRAMEWORKS_FOUND "${arrow_parquet_static_FRAMEWORKS}" "${arrow_parquet_static_FRAMEWORK_DIRS}")

set(arrow_parquet_static_LIB_TARGETS "")
set(arrow_parquet_static_NOT_USED "")
set(arrow_parquet_static_LIBS_FRAMEWORKS_DEPS ${arrow_parquet_static_FRAMEWORKS_FOUND} ${arrow_parquet_static_SYSTEM_LIBS} ${arrow_parquet_static_DEPENDENCIES})
conan_package_library_targets("${arrow_parquet_static_LIBS}"
                              "${arrow_parquet_static_LIB_DIRS}"
                              "${arrow_parquet_static_LIBS_FRAMEWORKS_DEPS}"
                              arrow_parquet_static_NOT_USED
                              arrow_parquet_static_LIB_TARGETS
                              ""
                              "arrow_parquet_static")

set(arrow_parquet_static_LINK_LIBS ${arrow_parquet_static_LIB_TARGETS} ${arrow_parquet_static_LIBS_FRAMEWORKS_DEPS})

set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH  ${CMAKE_PREFIX_PATH})


########## TARGETS ##########################################################################
#############################################################################################

########## COMPONENT arrow_static TARGET #################################################

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    # Target approach
    if(NOT TARGET arrow::arrow_static)
        add_library(arrow::arrow_static INTERFACE IMPORTED)
        set_target_properties(arrow::arrow_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
                              "${arrow_arrow_static_INCLUDE_DIRS}")
        set_target_properties(arrow::arrow_static PROPERTIES INTERFACE_LINK_DIRECTORIES
                              "${arrow_arrow_static_LIB_DIRS}")
        set_target_properties(arrow::arrow_static PROPERTIES INTERFACE_LINK_LIBRARIES
                              "${arrow_arrow_static_LINK_LIBS};${arrow_arrow_static_LINKER_FLAGS_LIST}")
        set_target_properties(arrow::arrow_static PROPERTIES INTERFACE_COMPILE_DEFINITIONS
                              "${arrow_arrow_static_COMPILE_DEFINITIONS}")
        set_target_properties(arrow::arrow_static PROPERTIES INTERFACE_COMPILE_OPTIONS
                              "${arrow_arrow_static_COMPILE_OPTIONS_C};${arrow_arrow_static_COMPILE_OPTIONS_CXX}")
    endif()
endif()

########## COMPONENT parquet_static TARGET #################################################

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    # Target approach
    if(NOT TARGET arrow::parquet_static)
        add_library(arrow::parquet_static INTERFACE IMPORTED)
        set_target_properties(arrow::parquet_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
                              "${arrow_parquet_static_INCLUDE_DIRS}")
        set_target_properties(arrow::parquet_static PROPERTIES INTERFACE_LINK_DIRECTORIES
                              "${arrow_parquet_static_LIB_DIRS}")
        set_target_properties(arrow::parquet_static PROPERTIES INTERFACE_LINK_LIBRARIES
                              "${arrow_parquet_static_LINK_LIBS};${arrow_parquet_static_LINKER_FLAGS_LIST}")
        set_target_properties(arrow::parquet_static PROPERTIES INTERFACE_COMPILE_DEFINITIONS
                              "${arrow_parquet_static_COMPILE_DEFINITIONS}")
        set_target_properties(arrow::parquet_static PROPERTIES INTERFACE_COMPILE_OPTIONS
                              "${arrow_parquet_static_COMPILE_OPTIONS_C};${arrow_parquet_static_COMPILE_OPTIONS_CXX}")
    endif()
endif()

########## GLOBAL TARGET ####################################################################

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    if(NOT TARGET arrow::arrow)
        add_library(arrow::arrow INTERFACE IMPORTED)
    endif()
    set_property(TARGET arrow::arrow APPEND PROPERTY
                 INTERFACE_LINK_LIBRARIES "${arrow_COMPONENTS}")
endif()

########## BUILD MODULES ####################################################################
#############################################################################################
########## COMPONENT arrow_static BUILD MODULES ##########################################

foreach(_BUILD_MODULE_PATH ${arrow_arrow_static_BUILD_MODULES_PATHS})
    include(${_BUILD_MODULE_PATH})
endforeach()
########## COMPONENT parquet_static BUILD MODULES ##########################################

foreach(_BUILD_MODULE_PATH ${arrow_parquet_static_BUILD_MODULES_PATHS})
    include(${_BUILD_MODULE_PATH})
endforeach()
